package no.hib.bridge.net;

import java.util.ArrayList;
import java.util.List;

import no.hib.bridge.beans.LinkBean;

import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

public class SupedoHttpClient {
	private static final String SERVER = "http://foxhole.no-ip.org";
	
	public void sendLinkToSupedo(LinkBean link)throws Exception{
		HttpClient client = new DefaultHttpClient();
		HttpPost post = new HttpPost(SERVER+"/com");
		
		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
		nameValuePairs.add(new BasicNameValuePair("address", "http://"+link.getAddress()));
		nameValuePairs.add(new BasicNameValuePair("name", link.getName()));
		nameValuePairs.add(new BasicNameValuePair("location", link.getLocation()));
		nameValuePairs.add(new BasicNameValuePair("section", link.getSection()));
		post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));
		
		client.execute(post);
		
	}
}
